/*预约表单验证*/
$("#game-form").bootstrapValidator({
	message:"这是无效的数据域",
	feedbackIcons: {/*input状态样式图片*/
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields:{
    	matchName:{
    		message:"无效",
    		validators:{
    			notEmpty:{
    				message:"赛事名称不可为空"
    			},
    			stringLength: {
                min: 3,
                max: 5,
                message: '赛事名称长度不正确'
                },
    		}
    	},
    	borrowAccount: {
            message:'无效',
            validators: {
                notEmpty: {
                    message: '用户账号不可为空'
                },
                stringLength: {
                min: 8,
                max: 12,
                message: '请输入正确的账号'
                },
            }
        },
        borrowName: {
            message:'无效',
            validators: {
                notEmpty: {
                    message: '用户名不能为空'
                },
                stringLength: {
                min: 2,
                max: 12,
                message: '请输入正确的用户名'
                },
            }
        },
        startTime: {
            message:'无效',
            validators: {
                notEmpty: {
                    message: '开始时间不能为空'
                },
            }
        },
        endTime: {
            message:'无效',
            validators: {
                notEmpty: {
                    message: '结束时间不能为空'
                },
            }
        },
        telephone: {
            message:'无效',
            validators: {
                notEmpty: {
                    message: '联系方式不能为空'
                },
                stringLength: {
                min: 11,
                max: 11,
                message: '请输入正确的手机号码'
                },
            }
        },
    }
});
/*获得当前时间*/
function p(s) {
    return s < 10 ? '0' + s: s;
};
var myDate = new Date();
//获取当前年
var year=myDate.getFullYear();
//获取当前月
var month=myDate.getMonth()+1;
//获取当前日
var date=myDate.getDate(); 
var h=myDate.getHours();       //获取当前小时数(0-23)
var m=myDate.getMinutes();     //获取当前分钟数(0-59)
var s=myDate.getSeconds();
var now=year+'-'+p(month)+"-"+p(date)+" "+p(h)+':'+p(m)+":"+p(s);

$(".tab1 a").click(function(){
	$("#matchName").val($(this).text());
	$('#startTime').val(now);
});
$("#addGame-btn").click(function(){
	$.ajax({
		type:"post",
		url:"addMatch",
		data:{
			matchName:$("#matchName").val(),
			borrowAccount:$("#borrowAccount").val(),
			borrowName:$("#borrowName").val(),
			startTime:$("#startTime").val(),
			endTime:$("#endTime").val(),
			telephone:$("#telephone").val(),
			placesId:$("#place-select").val(),
			equipId:$("#eq-select").val(),
			number:$("#number").val(),
		},
		success:function(result){
			alert(result.resultInfo);
		},
		error:function(){
			alert("添加失败");
		}
	});
})